/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;

/**
 * <p>Project: app2022 - PredicateDemo
 * <p>Powered by webrx On 2022-01-26 09:16:00
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class PredicateDemo {
    public static void main(String[] args) {
        var list = new ArrayList<Student>(List.of(
                new Student(1, "李四", "男", 20),
                new Student(2, "张三", "女", 20),
                new Student(3, "李勇", "男", 25),
                new Student(4, "王五", "男", 18),
                new Student(5, "李丽", "女", 22)
        ));

        //产生5个随机数（1-100),并输出
        Random rand = new Random();
        IntStream.generate(() -> rand.nextInt(1, 101)).limit(5).forEach(System.out::println);

        list.stream().filter(e -> e.getGender().equals("男")).map(e -> {
            e.setAge(e.getAge() + 2);
            return e;
        }).forEach(System.out::println);

        //list.stream().filter(a -> a.getName().startsWith("李")).forEach(e -> System.out.println(e.getName()));
        //list.stream().filter(s -> s.getGender().equals("男") && s.getAge() >= 20).forEach(System.out::println);
    }
}
